/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 * No deletion without permission, or be held responsible to law.
 * @author ThinkGem
 */
import { defHttp } from '/@/utils/http/axios';
import { useGlobSetting } from '/@/hooks/setting';
import { BasicModel, Page } from '../model/baseModel';

const { adminPath } = useGlobSetting();

export interface Shop extends BasicModel<Shop> {
  testInput?: string; // 单行文本
  testTextarea?: string; // 多行文本
  testSelect?: string; // 下拉框
  testSelectMultiple?: string; // 下拉多选
  testRadio?: string; // 单选框
  testCheckbox?: string; // 复选框
  testDate?: string; // 日期选择
  testDatetime?: string; // 日期时间
  testUser?: any; // 用户选择
  testOffice?: any; // 机构选择
  testAreaCode?: string; // 区域选择
  testAreaName?: string; // 区域名称
  testDataChildList?: any[]; // 子表列表
}

export function getBase64WithFile(file: File) {
  return new Promise<{
    result: string;
    file: File;
  }>((resolve, reject) => {
    const reader = new FileReader();
    reader.readAsDataURL(file);
    reader.onload = () => resolve({ result: reader.result as string, file });
    reader.onerror = (error) => reject(error);
  });
}


// 登录
export const saveFile = (params?: any) =>
  defHttp.post({ url: adminPath + '/shop/shopAppsetLogin/saveFile', params });


export const shopForm = (params?: Shop | any) =>
  defHttp.get<Shop>({ url: adminPath + '/shop/shopAppsetLogin/form', params });

export const shopSave = (params?: any, data?: Shop | any) =>
  defHttp.postJson<Shop>({ url: adminPath + '/shop/shopAppsetLogin/save', params, data });


// 首页
export const homeForm = (params?: Shop | any) =>
  defHttp.get<Shop>({ url: adminPath + '/shop/sethome/shopAppsetHome/pageForm', params });

export const homeSave = (params?: any, data?: Shop | any) =>
  defHttp.postJson<Shop>({ url: adminPath + '/shop/sethome/shopAppsetHome/pageSave', params, data });


// 详情
export const shopInvForm = (params?: Shop | any) =>
  defHttp.get<Shop>({ url: adminPath + '/shop/shopInv/form', params });

export const shopInvSave = (params?: any, data?: Shop | any) =>
  defHttp.postJson<Shop>({ url: adminPath + '/shop/shopInv/save', params, data });


